<?php
	$conn = mysql_connect("localhost","root","1234") or die(mysql_error());
	$db = mysql_select_db("book_db") or die("Cannot select db");
	mysql_query("SET character_set_results=tis620");
    mysql_query("SET character_set_client=tis620");
    mysql_query("SET character_set_connection=tis620");
	mysql_query("SET NAMES windows");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>รายชื่อพนักงาน</title>
<? 
$_SESSION["OfficerID"] =  $result["OfficerID"];
 $result = mysql_query("SELECT * FROM officer WHERE OfficerID = '".$_POST['id']."'");
 if($_POST[search]){
 $result = mysql_query("SELECT * FROM officer  WHERE  OfficerID LIKE '$_POST[keyword]' " );
}else{
 $result = mysql_query("SELECT *  FROM officer");
}
?>
<style type="text/css">
body {
	background-color: #82AFFB;
}
</style>
</head>

<body>
<table width="913" height="608" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="133" colspan="8"><img src="../image/mix.jpg" width="860" height="175" /></td>
  </tr>
  <tr>
    <td width="144" height="46"><a href="list_officer.php"><img src="../image/menuadmin1.jpg" width="140" height="40" /></a></td>
    <td width="144"><a href="file:///G|/pppppppppppppppppppppppppp/bok/add_members.php"><img src="../image/menuadmin2.jpg" width="140" height="40" /></a></td>
    <td width="144"><a href="file:///G|/pppppppppppppppppppppppppp/bok/Addbook.html"><img src="../image/menuadmin3.jpg" width="140" height="40" /></a></td>
    <td width="144"><a href="file:///G|/pppppppppppppppppppppppppp/bok/add_pub.php"><img src="../image/menuadmin4.jpg" width="140" height="40" /></a></td>
    <td width="138"><img src="../image/menuadmin5.jpg" width="138" height="46" /></td>
    <td width="382"><img src="../image/menuadmin8.jpg" width="144" height="46" /></td>
  </tr>
  <tr>
    <td colspan="8"><form id="form1" name="form1" method="post" action="">
      <p><center> 
        <p>แสดงรายชื่อพนักงาน</p>
        <p><a href="add_officer.php">เพิ่มข้อมูลพนักงาน</a></p>
        </center></p>
      <table width="1096" height="101" border="1" align="center">
        <tr>
          <center><td width="90" height="33" bgcolor="#FFFFFF">รหัสพนักงาน</td></center>
          <center><td width="167" bgcolor="#FFFFFF">ชื่อ - นามสกุล</td></center>
          <center><td width="68" bgcolor="#FFFFFF">เพศ</td></center>
          <center><td width="142" bgcolor="#FFFFFF">ปี/เดือน/วัน เกิด</td></center>
          <center><td width="155" bgcolor="#FFFFFF">เลขที่บัตรประชาชน</td></center>
          <center><td width="60" bgcolor="#FFFFFF">ที่อยู่</td></center>
          <center><td width="129" bgcolor="#FFFFFF">เบอร์โทรศัพท์</td></center>
          <center><td width="73" bgcolor="#FFFFFF">อีเมล์</td></center>
          <center><td width="81" bgcolor="#FFFFFF">แก้ไขข้อมูล</td></center>
          <center><td width="67" bgcolor="#FFFFFF">ลบข้อมูล</td></center>
          <? 
   $rows = mysql_num_rows($result);
   if($rows > 0){
   for ($i=0;$i<$rows; $i++){
     mysql_data_seek($result,$i);
         $data[$i] = mysql_fetch_array($result)
 ?>
          <tr>
            <td align="center"><? echo  $data[$i]['OfficerID'] ?>&nbsp;</td>
            <td align="center"><? echo $data[$i]['OfficerName']; ?>&nbsp;</td>
            <td align="center"><? echo $data[$i]['OfficerSex']; ?>&nbsp;</td>
            <td align="center"><? echo  $data[$i]['OfficerBirth'] ?>&nbsp;</td>
            <td align="center"><? echo  $data[$i]['OfficerNum'] ?>&nbsp;</td>
            <td align="center"><? echo  $data[$i]['OfficerAddress'] ?>&nbsp;</td>
            <td align="center"><? echo  $data[$i]['OfficerTel'] ?>&nbsp;</td>
            <td align="center"><? echo  $data[$i]['OfficerEmail'] ?>&nbsp;</td>
            <td align="center"><a href="edit_officer.php?OfficerID=<?=$data[$i]["OfficerID"];?>">แก้ไขข้อมูล</a></td>
            <td align="center"><a href="JavaScript:if(confirm('Confirm Delete?')==true){window.location='delete_officer.php?OfficerID=<?php echo $data[$i]["OfficerID"];?>';}">ลบข้อมูล</a></td>
            </tr>
        <? 
   }  // end for
 }  // end if rows > 0
 ?>
        </table>
    </form></td>
  </tr>
</table>
</body>
</html>